home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Entertainment / MacMud / Unix / sys⁄ioctl.h < prev    next >
Encoding:
Text File  |  1989-06-27  |  13.6 KB  |  316 lines  |  [TEXT/MPS ]

  1. /*
  2.  * Copyright (c) 1982, 1986 Regents of the University of California.
  3.  * All rights reserved.  The Berkeley software License Agreement
  4.  * specifies the terms and conditions for redistribution.
  5.  *
  6.  *    @(#)ioctl.h 1.3 86/10/13 SMI; from UCB 7.1 6/5/86
  7.  */
  8.  
  9. /*
  10.  * Ioctl definitions
  11.  */
  12. #ifndef    _IOCTL_
  13. #define    _IOCTL_
  14.  
  15. struct tchars {
  16.     char    t_intrc;    /* interrupt */
  17.     char    t_quitc;    /* quit */
  18.     char    t_startc;    /* start output */
  19.     char    t_stopc;    /* stop output */
  20.     char    t_eofc;        /* end-of-file */
  21.     char    t_brkc;        /* input delimiter (like nl) */
  22. };
  23. struct ltchars {
  24.     char    t_suspc;    /* stop process signal */
  25.     char    t_dsuspc;    /* delayed stop process signal */
  26.     char    t_rprntc;    /* reprint line */
  27.     char    t_flushc;    /* flush output (toggles) */
  28.     char    t_werasc;    /* word erase */
  29.     char    t_lnextc;    /* literal next character */
  30. };
  31.  
  32. /*
  33.  * Structure for TIOCGETP and TIOCSETP ioctls.
  34.  */
  35.  
  36. #ifndef _SGTTYB_
  37. #define    _SGTTYB_
  38. struct sgttyb {
  39.     char    sg_ispeed;        /* input speed */
  40.     char    sg_ospeed;        /* output speed */
  41.     char    sg_erase;        /* erase character */
  42.     char    sg_kill;        /* kill character */
  43.     short    sg_flags;        /* mode flags */
  44. };
  45. #endif
  46.  
  47. /*
  48.  * Window/terminal size structure.
  49.  * This information is stored by the kernel
  50.  * in order to provide a consistent interface,
  51.  * but is not used by the kernel.
  52.  *
  53.  * Type must be "unsigned short" so that types.h not required.
  54.  */
  55. struct winsize {
  56.     unsigned short    ws_row;        /* rows, in characters */
  57.     unsigned short    ws_col;        /* columns, in characters */
  58.     unsigned short    ws_xpixel;    /* horizontal size, pixels - not used */
  59.     unsigned short    ws_ypixel;    /* vertical size, pixels - not used */
  60. };
  61.  
  62. /*
  63.  * Sun version of same.
  64.  */
  65. struct ttysize {
  66.     int    ts_lines;    /* number of lines on terminal */
  67.     int    ts_cols;    /* number of columns on terminal */
  68. };
  69.  
  70. #ifndef _IO
  71. /*
  72.  * Ioctl's have the command encoded in the lower word,
  73.  * and the size of any in or out parameters in the upper
  74.  * word.  The high 2 bits of the upper word are used
  75.  * to encode the in/out status of the parameter; for now
  76.  * we restrict parameters to at most 128 bytes.
  77.  */
  78. #define    IOCPARM_MASK    0x7f        /* parameters must be < 128 bytes */
  79. #define    IOC_VOID    0x20000000    /* no parameters */
  80. #define    IOC_OUT        0x40000000    /* copy out parameters */
  81. #define    IOC_IN        0x80000000    /* copy in parameters */
  82. #define    IOC_INOUT    (IOC_IN|IOC_OUT)
  83. /* the 0x20000000 is so we can distinguish new ioctl's from old */
  84. #define    _IO(x,y)    (IOC_VOID|('x'<<8)|y)
  85. #define    _IOR(x,y,t)    (IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|('x'<<8)|y)
  86. #define    _IORN(x,y,t)    (IOC_OUT|(((t)&IOCPARM_MASK)<<16)|('x'<<8)|y)
  87. #define    _IOW(x,y,t)    (IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|('x'<<8)|y)
  88. #define    _IOWN(x,y,t)    (IOC_IN|(((t)&IOCPARM_MASK)<<16)|('x'<<8)|y)
  89. /* this should be _IORW, but stdio got there first */
  90. #define    _IOWR(x,y,t)    (IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|('x'<<8)|y)
  91. #define    _IOWRN(x,y,t)    (IOC_INOUT|(((t)&IOCPARM_MASK)<<16)|('x'<<8)|y)
  92. #endif
  93.  
  94. /*
  95.  * tty ioctl commands
  96.  */
  97. #define    TIOCGETD    _IOR(t, 0, int)        /* get line discipline */
  98. #define    TIOCSETD    _IOW(t, 1, int)        /* set line discipline */
  99. #define    TIOCHPCL    _IO(t, 2)        /* hang up on last close */
  100. #define    TIOCMODG    _IOR(t, 3, int)        /* get modem control state */
  101. #define    TIOCMODS    _IOW(t, 4, int)        /* set modem control state */
  102. #define        TIOCM_LE    0001        /* line enable */
  103. #define        TIOCM_DTR    0002        /* data terminal ready */
  104. #define        TIOCM_RTS    0004        /* request to send */
  105. #define        TIOCM_ST    0010        /* secondary transmit */
  106. #define        TIOCM_SR    0020        /* secondary receive */
  107. #define        TIOCM_CTS    0040        /* clear to send */
  108. #define        TIOCM_CAR    0100        /* carrier detect */
  109. #define        TIOCM_CD    TIOCM_CAR
  110. #define        TIOCM_RNG    0200        /* ring */
  111. #define        TIOCM_RI    TIOCM_RNG
  112. #define        TIOCM_DSR    0400        /* data set ready */
  113. #define    TIOCGETP    _IOR(t, 8,struct sgttyb)/* get parameters -- gtty */
  114. #define    TIOCSETP    _IOW(t, 9,struct sgttyb)/* set parameters -- stty */
  115. #define    TIOCSETN    _IOW(t,10,struct sgttyb)/* as above, but no flushtty */
  116. #define    TIOCEXCL    _IO(t, 13)        /* set exclusive use of tty */
  117. #define    TIOCNXCL    _IO(t, 14)        /* reset exclusive use of tty */
  118. #define    TIOCFLUSH    _IOW(t, 16, int)    /* flush buffers */
  119. #define    TIOCSETC    _IOW(t,17,struct tchars)/* set special characters */
  120. #define    TIOCGETC    _IOR(t,18,struct tchars)/* get special characters */
  121. #define        TANDEM        0x00000001    /* send stopc on out q full */
  122. #define        CBREAK        0x00000002    /* half-cooked mode */
  123. #define        LCASE        0x00000004    /* simulate lower case */
  124. #define        ECHO        0x00000008    /* echo input */
  125. #define        CRMOD        0x00000010    /* map \r to \r\n on output */
  126. #define        RAW        0x00000020    /* no i/o processing */
  127. #define        ODDP        0x00000040    /* get/send odd parity */
  128. #define        EVENP        0x00000080    /* get/send even parity */
  129. #define        ANYP        0x000000c0    /* get any parity/send none */
  130. #define        NLDELAY        0x00000300    /* \n delay */
  131. #define            NL0    0x00000000
  132. #define            NL1    0x00000100    /* tty 37 */
  133. #define            NL2    0x00000200    /* vt05 */
  134. #define            NL3    0x00000300
  135. #define        TBDELAY        0x00000c00    /* horizontal tab delay */
  136. #define            TAB0    0x00000000
  137. #define            TAB1    0x00000400    /* tty 37 */
  138. #define            TAB2    0x00000800
  139. #define        XTABS        0x00000c00    /* expand tabs on output */
  140. #define        CRDELAY        0x00003000    /* \r delay */
  141. #define            CR0    0x00000000
  142. #define            CR1    0x00001000    /* tn 300 */
  143. #define            CR2    0x00002000    /* tty 37 */
  144. #define            CR3    0x00003000    /* concept 100 */
  145. #define        VTDELAY        0x00004000    /* vertical tab delay */
  146. #define            FF0    0x00000000
  147. #define            FF1    0x00004000    /* tty 37 */
  148. #define        BSDELAY        0x00008000    /* \b delay */
  149. #define            BS0    0x00000000
  150. #define            BS1    0x00008000
  151. #define     ALLDELAY    (NLDELAY|TBDELAY|CRDELAY|VTDELAY|BSDELAY)
  152. #define        CRTBS        0x00010000    /* do backspacing for crt */
  153. #define        PRTERA        0x00020000    /* \ ... / erase */
  154. #define        CRTERA        0x00040000    /* " \b " to wipe out char */
  155. #define        TILDE        0x00080000    /* hazeltine tilde kludge */
  156. #define        MDMBUF        0x00100000    /* start/stop output on carrier intr */
  157. #define        LITOUT        0x00200000    /* literal output */
  158. #define        TOSTOP        0x00400000    /* SIGTTOU on background output */
  159. #define        FLUSHO        0x00800000    /* flush output to terminal */
  160. #define        NOHANG        0x01000000    /* no SIGHUP on carrier drop */
  161. #define        L001000        0x02000000
  162. #define        CRTKIL        0x04000000    /* kill line with " \b " */
  163. #define        PASS8        0x08000000
  164. #define        CTLECH        0x10000000    /* echo control chars as ^X */
  165. #define        PENDIN        0x20000000    /* tp->t_rawq needs reread */
  166. #define        DECCTQ        0x40000000    /* only ^Q starts after ^S */
  167. #define        NOFLSH        0x80000000    /* no output flush on signal */
  168. /* locals, from 127 down */
  169. #define    TIOCLBIS    _IOW(t, 127, int)    /* bis local mode bits */
  170. #define    TIOCLBIC    _IOW(t, 126, int)    /* bic local mode bits */
  171. #define    TIOCLSET    _IOW(t, 125, int)    /* set entire local mode word */
  172. #define    TIOCLGET    _IOR(t, 124, int)    /* get local modes */
  173. #define        LCRTBS        (CRTBS>>16)
  174. #define        LPRTERA        (PRTERA>>16)
  175. #define        LCRTERA        (CRTERA>>16)
  176. #define        LTILDE        (TILDE>>16)
  177. #define        LMDMBUF        (MDMBUF>>16)
  178. #define        LLITOUT        (LITOUT>>16)
  179. #define        LTOSTOP        (TOSTOP>>16)
  180. #define        LFLUSHO        (FLUSHO>>16)
  181. #define        LNOHANG        (NOHANG>>16)
  182. #define        LCRTKIL        (CRTKIL>>16)
  183. #define        LPASS8        (PASS8>>16)
  184. #define        LCTLECH        (CTLECH>>16)
  185. #define        LPENDIN        (PENDIN>>16)
  186. #define        LDECCTQ        (DECCTQ>>16)
  187. #define        LNOFLSH        (NOFLSH>>16)
  188. #define    TIOCSBRK    _IO(t, 123)        /* set break bit */
  189. #define    TIOCCBRK    _IO(t, 122)        /* clear break bit */
  190. #define    TIOCSDTR    _IO(t, 121)        /* set data terminal ready */
  191. #define    TIOCCDTR    _IO(t, 120)        /* clear data terminal ready */
  192. #define    TIOCGPGRP    _IOR(t, 119, int)    /* get pgrp of tty */
  193. #define    TIOCSPGRP    _IOW(t, 118, int)    /* set pgrp of tty */
  194. #define    TIOCSLTC    _IOW(t,117,struct ltchars)/* set local special chars */
  195. #define    TIOCGLTC    _IOR(t,116,struct ltchars)/* get local special chars */
  196. #define    TIOCOUTQ    _IOR(t, 115, int)    /* output queue size */
  197. #define    TIOCSTI        _IOW(t, 114, char)    /* simulate terminal input */
  198. #define    TIOCNOTTY    _IO(t, 113)        /* void tty association */
  199. #define    TIOCPKT        _IOW(t, 112, int)    /* pty: set/clear packet mode */
  200. #define        TIOCPKT_DATA        0x00    /* data packet */
  201. #define        TIOCPKT_FLUSHREAD    0x01    /* flush packet */
  202. #define        TIOCPKT_FLUSHWRITE    0x02    /* flush packet */
  203. #define        TIOCPKT_STOP        0x04    /* stop output */
  204. #define        TIOCPKT_START        0x08    /* start output */
  205. #define        TIOCPKT_NOSTOP        0x10    /* no more ^S, ^Q */
  206. #define        TIOCPKT_DOSTOP        0x20    /* now do ^S ^Q */
  207. #define    TIOCSTOP    _IO(t, 111)        /* stop output, like ^S */
  208. #define    TIOCSTART    _IO(t, 110)        /* start output, like ^Q */
  209. #define    TIOCMSET    _IOW(t, 109, int)    /* set all modem bits */
  210. #define    TIOCMBIS    _IOW(t, 108, int)    /* bis modem bits */
  211. #define    TIOCMBIC    _IOW(t, 107, int)    /* bic modem bits */
  212. #define    TIOCMGET    _IOR(t, 106, int)    /* get all modem bits */
  213. #define    TIOCREMOTE    _IOW(t, 105, int)    /* remote input editing */
  214. #define    TIOCGWINSZ    _IOR(t, 104, struct winsize)    /* get window size */
  215. #define    TIOCSWINSZ    _IOW(t, 103, struct winsize)    /* set window size */
  216. #define    TIOCUCNTL    _IOW(t, 102, int)    /* pty: set/clr usr cntl mode */
  217.  
  218. /*
  219.  * Sun-specific ioctls, which will be moved to the Sun-specific range.
  220.  * The old codes will be kept around for binary compatibility; the
  221.  * codes for TIOCCONS and TIOCGSIZE don't collide with the 4.3BSD codes
  222.  * because the structure size and copy direction fields are different.
  223.  * The new codes are here to ease the transition internally, not for
  224.  * customer use.
  225.  *
  226.  * Unfortunately, the old TIOCSSIZE code does collide with TIOCSWINSZ,
  227.  * but they can be disambiguated by checking whether a "struct ttysize"
  228.  * structure's "ts_lines" field is greater than 64K or not.  If so,
  229.  * it's almost certainly a "struct winsize" instead.
  230.  */
  231. #define    _O_TIOCCONS    _IO(t, 104)        /* get console I/O */
  232. #define    _O_TIOCSSIZE    _IOW(t,103,struct ttysize)/* get tty size */
  233. #define    _O_TIOCGSIZE    _IOR(t,102,struct ttysize)/* get tty size */
  234. #define    _N_TIOCCONS    _IO(t, 36)        /* get console I/O */
  235. #define    _N_TIOCSSIZE    _IOW(t,37,struct ttysize)/* set tty size */
  236. #define    _N_TIOCGSIZE    _IOR(t,38,struct ttysize)/* get tty size */
  237.  
  238. /*
  239.  * Sun-specific ioctls.
  240.  */
  241. #define TIOCTCNTL    _IOW(t, 32, int)    /* pty: set/clr intercept ioctl mode */
  242. #define TIOCSIGNAL    _IOW(t, 33, int)    /* pty: send signal to slave */
  243. #define    TIOCSETX    _IOW(t, 34, int)    /* set extra modes for S5 compatibility */
  244. #define    TIOCGETX    _IOR(t, 35, int)    /* get extra modes for S5 compatibility */
  245. #define        NOPOST        0x00000001    /* no processing on output (LITOUT with 7 bits + parity) */
  246. #define        NOISIG        0x00000002    /* disable all signal-generating characters */
  247. #define        STOPB        0x00000004    /* two stop bits */
  248. #define    TIOCCONS    _IO(t, 104)        /* get console I/O */
  249. #define    TIOCSSIZE    _IOW(t,103,struct ttysize)/* set tty size */
  250. #define    TIOCGSIZE    _IOR(t,102,struct ttysize)/* get tty size */
  251.  
  252. #define    OTTYDISC    0        /* old, v7 std tty driver */
  253. #define    NETLDISC    1        /* line discip for berk net */
  254. #define    NTTYDISC    2        /* new tty discipline */
  255. #define    TABLDISC    3        /* hitachi tablet discipline */
  256. #define    NTABLDISC    4        /* gtco tablet discipline */
  257. #define    MOUSELDISC    5        /* mouse discipline */
  258. #define    KBDLDISC    6        /* up/down keyboard trans (console) */
  259.  
  260. #define    FIOCLEX        _IO(f, 1)        /* set exclusive use on fd */
  261. #define    FIONCLEX    _IO(f, 2)        /* remove exclusive use */
  262. /* another local */
  263. #define    FIONREAD    _IOR(f, 127, int)    /* get # bytes to read */
  264. #define    FIONBIO        _IOW(f, 126, int)    /* set/clear non-blocking i/o */
  265. #define    FIOASYNC    _IOW(f, 125, int)    /* set/clear async i/o */
  266. #define    FIOSETOWN    _IOW(f, 124, int)    /* set owner */
  267. #define    FIOGETOWN    _IOR(f, 123, int)    /* get owner */
  268.  
  269. /* socket i/o controls */
  270. #define    SIOCSHIWAT    _IOW(s,  0, int)        /* set high watermark */
  271. #define    SIOCGHIWAT    _IOR(s,  1, int)        /* get high watermark */
  272. #define    SIOCSLOWAT    _IOW(s,  2, int)        /* set low watermark */
  273. #define    SIOCGLOWAT    _IOR(s,  3, int)        /* get low watermark */
  274. #define    SIOCATMARK    _IOR(s,  7, int)        /* at oob mark? */
  275. #define    SIOCSPGRP    _IOW(s,  8, int)        /* set process group */
  276. #define    SIOCGPGRP    _IOR(s,  9, int)        /* get process group */
  277.  
  278. #define    SIOCADDRT    _IOW(r, 10, struct rtentry)    /* add route */
  279. #define    SIOCDELRT    _IOW(r, 11, struct rtentry)    /* delete route */
  280.  
  281. #define    SIOCSIFADDR    _IOW(i, 12, struct ifreq)    /* set ifnet address */
  282. #define    SIOCGIFADDR    _IOWR(i,13, struct ifreq)    /* get ifnet address */
  283. #define    SIOCSIFDSTADDR    _IOW(i, 14, struct ifreq)    /* set p-p address */
  284. #define    SIOCGIFDSTADDR    _IOWR(i,15, struct ifreq)    /* get p-p address */
  285. #define    SIOCSIFFLAGS    _IOW(i, 16, struct ifreq)    /* set ifnet flags */
  286. #define    SIOCGIFFLAGS    _IOWR(i,17, struct ifreq)    /* get ifnet flags */
  287. #define    SIOCSIFMEM    _IOW(i, 18, struct ifreq)    /* set interface mem */
  288. #define    SIOCGIFMEM    _IOWR(i,19, struct ifreq)    /* get interface mem */
  289. #define    SIOCGIFCONF    _IOWR(i,20, struct ifconf)    /* get ifnet list */
  290. #define    SIOCSIFMTU    _IOW(i, 21, struct ifreq)    /* set if_mtu */
  291. #define    SIOCGIFMTU    _IOWR(i,22, struct ifreq)    /* get if_mtu */
  292.  
  293.     /* from 4.3BSD */
  294. #define    SIOCGIFBRDADDR    _IOWR(i,23, struct ifreq)    /* get broadcast addr */
  295. #define    SIOCSIFBRDADDR    _IOW(i,24, struct ifreq)    /* set broadcast addr */
  296. #define    SIOCGIFNETMASK    _IOWR(i,25, struct ifreq)    /* get net addr mask */
  297. #define    SIOCSIFNETMASK    _IOW(i,26, struct ifreq)    /* set net addr mask */
  298. #define    SIOCGIFMETRIC    _IOWR(i,27, struct ifreq)    /* get IF metric */
  299. #define    SIOCSIFMETRIC    _IOW(i,28, struct ifreq)    /* set IF metric */
  300.  
  301. #define    SIOCSARP    _IOW(i, 30, struct arpreq)    /* set arp entry */
  302. #define    SIOCGARP    _IOWR(i,31, struct arpreq)    /* get arp entry */
  303. #define    SIOCDARP    _IOW(i, 32, struct arpreq)    /* delete arp entry */
  304. #define SIOCUPPER       _IOW(i, 40, struct ifreq)       /* attach upper layer */
  305. #define SIOCLOWER       _IOW(i, 41, struct ifreq)       /* attach lower layer */
  306. #define SIOCSETSYNC    _IOW(i,  44, struct ifreq)    /* set syncmode */
  307. #define SIOCGETSYNC    _IOWR(i, 45, struct ifreq)    /* get syncmode */
  308. #define SIOCSSDSTATS    _IOWR(i, 46, struct ifreq)    /* sync data stats */
  309. #define SIOCSSESTATS    _IOWR(i, 47, struct ifreq)    /* sync error stats */
  310.  
  311. /* protocol i/o controls */
  312. #define SIOCSNIT    _IOW(p,  0, struct nit_ioc)    /* set nit modes */
  313. #define SIOCGNIT    _IOWR(p, 1, struct nit_ioc)    /* get nit modes */
  314.  
  315. #endif
  316.